#
# @lc app=leetcode.cn id=860 lang=python3
#
# [860] 柠檬水找零
#

# @lc code=start
from typing import List

class Solution:
    def lemonadeChange(self, bills: List[int]) -> bool:
        fiveCount = 0
        tenCount = 0
        
        for bill in bills:
            if bill == 5:
                fiveCount += 1
            elif bill == 10:
                fiveCount -= 1
                tenCount += 1
            else:
                if tenCount > 1:
                    tenCount -= 1
                    fiveCount -= 1
                else:
                    fiveCount -= 1
    
            if fiveCount < 0 or tenCount < 0:
                return False
            
        return True
    
Solution().lemonadeChange([5,5,10,20,5,5,5,5,5,5,5,5,5,10,5,5,20,5,20,5])
# @lc code=end

